package com.first.teacher.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.first.common.pojo.EduTeacher;
import com.first.common.vo.Result;
import com.first.teacher.service.TeacherService;
import com.first.teacher.vo.TeacherVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: first-project
 * @description:
 * @author: 马英贤
 * @create: 2023-05-26 16:03
 **/
@RestController
@RequestMapping("/core/teacher")
@Api(tags = "讲师管理类")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @ApiOperation("分页条件查询")
    @PostMapping("/list/{current}/{pageSize}")
    public Result list(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody TeacherVo teacherVo){
        Page<EduTeacher> teacherPage = teacherService.findByPage(current,pageSize,teacherVo);
        return Result.success(teacherPage);
    }

    @ApiOperation("修改导师状态")
    @PostMapping("/status")
    public Result status(@RequestParam String id,@RequestParam String status){
        int row = teacherService.updateStatus(id, status);
        return Result.success();
    }

    @ApiOperation("修改导师信息")
    @PostMapping("/updateTeacher")
    public Result update(@RequestBody EduTeacher eduTeacher){
        EduTeacher teacher = new EduTeacher();
        teacher.setId(eduTeacher.getId());
        teacher.setEmail(eduTeacher.getEmail());
        teacher.setName(eduTeacher.getName());
        teacher.setIntro(eduTeacher.getIntro());
        teacher.setMobile(eduTeacher.getMobile());
        teacher.setGmtModified(eduTeacher.getGmtModified());
        teacher.setAvatar(eduTeacher.getAvatar());
        teacherService.update(teacher);
        return Result.success();
    }



}
